package com.zy.struts.dao;

public class DAOFactory {

	private static DAOFactory daoFactory=new DAOFactory();
	
	
	private DAOFactory(){
		
	}
	public static DAOFactory getInstance(){
		return daoFactory;
	}
	
	public Object getDAO(String dao){
	
		if(null!=dao&&!"".equals(dao)){
			try {
				//System.out.println("123");
				Class clazz=Class.forName("com.zy.struts.dao."+dao+"Impl");
				return clazz.newInstance();
			    
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null;
	}
	
	public static void main(String[] arg){
		UserDAO udao=(UserDAO)DAOFactory.getInstance().getDAO("UserDAO");
		System.out.println(udao);
	}
}
